<?php

require_once(WSB_MODULES_PATH .'sherpa/models/BaseGateway.php');
require_once(WSB_MODULES_PATH .'sherpa/models/Coupons.php');

class Sherpa_Model_CouponGateway extends Sherpa_Model_BaseGateway
{

	/**
	 * @param string $couponCode
	 * @return Sherpa_Model_Coupon
	 */
	public function fetchCoupon($couponCode)
	{
		$select = $this->getDbSelect();
		$select->from(array('b' => 'sherpa_coupons'));
		$select->where('code=?', $couponCode);
		return new Sherpa_Model_Coupon($select->query()->fetch());
	}

}
